<?php
define("_needlogin", "0");
define("_access", "1");
include_once("include/db.config.php"); 
if (isset($_POST['submit'])) {
  $verify=$_POST['verify'];
  $verify_=$_SESSION['verify'];
  if(!isset($verify)||$verify!=$verify_){
        echo '<script charset="UTF-8">alert("验证码错误!");location.href="./login.php";</script>';
        die();
  }
  $email = mysql_real_escape_string($_POST['email']);
  $password = mysql_real_escape_string($_POST['password']);
  $sql = "SELECT * from team where email='$email' and password='$password'";
  $r = getOne($sql);
  if(!$r){
    echo '<script charset="UTF-8">alert("账号或密码错误");location.href="./login.php";</script>';
  }else if($r['status']==0){
    echo '<script charset="UTF-8">alert("该账号还未通过审核，请耐心等待");location.href="./login.php";</script>';
  }
  else{
    $_SESSION['islogin'] = 1;
    $_SESSION['team'] = $r;
    setcookie("ssid",md5($r['name'].$r['school']));
    echo '<script charset="UTF-8">location.href="./notice.php";</script>';
  }
}
?>
<!DOCTYPE html>
<html>
<?php include("include/head.php"); ?>
<body>
<?php include("include/nav.php"); ?>
<div class="row login-wrap">
    <div class="row">
    </div>
    <div class="login-form">
    <h1>登录</h1>
    <form method="POST" action="login.php">
        <input class="radius" type='text' name='email' placeholder='登录邮箱'><br/>
        <input class="radius" type='password' name='password' placeholder='密码'><br/>
        <input id="r_verify" class="radius" type='text' name='verify' placeholder='验证码' onclick="clearThis('#r_verify')"><br/>
        <img src="getVerify.php" alt="" onclick="this.src='getVerify.php?'+ new Date().getTime();">
        <p>密码忘记或账号问题请直接联系竞赛组委会</p>
        <button class="radius" name="submit" type='submit'>登录</button>
    </form>
    </div>
</div>
<?php include("include/script.php"); ?>
</body>
</html>